package cn.icanci.loopstack.ras.common.model;

import java.util.Date;
import java.util.Objects;
import java.util.StringJoiner;

/**
 * @author icanci
 * @since 1.0 Created in 2023/01/18 22:06
 */
public class Instance {
    /**
     * AppId 唯一
     */
    private String appId;
    /**
     * 客户端/服务端注册地址
     */
    private String address;
    /**
     * 客户端/服务端注册端口
     */
    private int    port;
    /**
     * 创建时间
     */
    private Date   createTime;
    /**
     * 更新时间
     */
    private Date   updateTime;
    /**
     * 是否删除：状态 1无效，0有效(主动设置)
     */
    private int    isDelete;
    /**
     * 是否在线 1不在线，0在线(客户端注册处理)
     */
    private int    online;

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public int getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(int isDelete) {
        this.isDelete = isDelete;
    }

    public int getOnline() {
        return online;
    }

    public void setOnline(int online) {
        this.online = online;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        Instance instance = (Instance) o;
        return port == instance.port && Objects.equals(appId, instance.appId) && Objects.equals(address, instance.address);
    }

    @Override
    public int hashCode() {
        return Objects.hash(appId, address, port);
    }

    @Override
    public String toString() {
        return new StringJoiner(",").add("appId=" + appId).add("address=" + address).add("port=" + port).add("createTime=" + createTime).add("updateTime=" + updateTime)
            .add("isDelete=" + isDelete).add("online=" + online).toString();
    }
}
